﻿using System;
using System.Diagnostics.Tracing;
using System.Threading;

namespace Sustainalytics.GCCS
{
    public class GCCEventSource : EventSource
    {
        private static Lazy<GCCEventSource> _lazyLog = new Lazy<GCCEventSource>(InitLog, LazyThreadSafetyMode.ExecutionAndPublication);

        public static GCCEventSource Log => _lazyLog.Value;

        [NonEvent]
        private static GCCEventSource InitLog()
        {
            var log = new GCCEventSource();
            log.Ping();

            return log;
        }

        [Event(1, Level = EventLevel.LogAlways)]
        public void Ping()
        {
            if (IsEnabled())
            {
                WriteEvent(1);
            }
        }

        #region GCOverallCompanySummaryExtended

        [Event(100, Level = EventLevel.Informational)]
        public void GCOverallCompanySummaryExtended_GetCount(string args)
        {
            if (this.IsEnabled())
            {
                WriteEvent(100, args);
            }
        }

        [Event(101, Level = EventLevel.Informational)]
        public void GCOverallCompanySummaryExtended_GetCount_Success(string args)
        {
            if (this.IsEnabled())
            {
                WriteEvent(101, args);
            }
        }

        [NonEvent]
        public void GCOverallCompanySummaryExtended_GetCount_Error(string args, Exception ex)
        {
            if (this.IsEnabled())
            {
                GCOverallCompanySummaryExtended_GetCount_Error(args, ex.ToString());
            }
        }

        [Event(102, Level = EventLevel.Error)]
        public void GCOverallCompanySummaryExtended_GetCount_Error(string args, string err)
        {
            if (this.IsEnabled())
            {
                WriteEvent(102, args, err);
            }
        }

        [Event(200, Level = EventLevel.Informational)]
        public void GCOverallCompanySummaryExtended_GetList(string args)
        {
            if (IsEnabled())
            {
                WriteEvent(200, args);
            }
        }

        [Event(201, Level = EventLevel.Informational)]
        public void GCOverallCompanySummaryExtended_GetList_Success(string args)
        {
            if (IsEnabled())
            {
                WriteEvent(201, args);
            }
        }

        [NonEvent]
        public void GCOverallCompanySummaryExtended_GetList_Error(string args, Exception ex)
        {
            if (IsEnabled())
            {
                GCOverallCompanySummaryExtended_GetList_Error(args, ex);
            }
        }

        [Event(202, Level = EventLevel.Error)]
        public void GCOverallCompanySummaryExtended_GetList_Error(string args, string err)
        {
            if (IsEnabled())
            {
                WriteEvent(202, args, err);
            }
        }

        #endregion GCOverallCompanySummaryExtended

        #region GCOverallCompanySummary

        [Event(300, Level = EventLevel.Informational)]
        public void GCOverallCompanySummary_GetByCompany(Guid companyId, string args)
        {
            if (IsEnabled())
            {
                WriteEvent(300, companyId, args);
            }
        }

        [Event(301, Level = EventLevel.Informational)]
        public void GCOverallCompanySummary_GetByCompany_Success(Guid companyId, string args)
        {
            if (IsEnabled())
            {
                WriteEvent(301, companyId, args);
            }
        }

        [NonEvent]
        public void GCOverallCompanySummary_GetByCompany_Error(Guid companyId, string args, Exception ex)
        {
            if (IsEnabled())
            {
                GCOverallCompanySummary_GetByCompany_Error(companyId, args, ex.ToString());
            }
        }

        [Event(302, Level = EventLevel.Error)]
        public void GCOverallCompanySummary_GetByCompany_Error(Guid companyId, string args, string err)
        {
            if (IsEnabled())
            {
                WriteEvent(302, companyId, args, err);
            }
        }

        #endregion GCOverallCompanySummary

        #region GCPrincipleConclusion

        [Event(400, Level = EventLevel.Informational)]
        public void GCPrincipleConclusion_GetByPrincipleSummary(Guid principleSummaryId)
        {
            if (IsEnabled())
            {
                WriteEvent(400, principleSummaryId);
            }
        }

        [Event(401, Level = EventLevel.Informational)]
        public void GCPrincipleConclusion_GetByPrincipleSummary_Success(Guid principleSummaryId)
        {
            if (IsEnabled())
            {
                WriteEvent(401, principleSummaryId);
            }
        }

        [NonEvent]
        public void GCPrincipleConclusion_GetByPrincipleSummary_Error(Guid principleSummaryId, Exception ex)
        {
            if (IsEnabled())
            {
                GCPrincipleConclusion_GetByPrincipleSummary_Error(principleSummaryId, ex.ToString());
            }
        }

        [Event(402, Level = EventLevel.Error)]
        public void GCPrincipleConclusion_GetByPrincipleSummary_Error(Guid principleSummaryId, string err)
        {
            if (IsEnabled())
            {
                WriteEvent(402, principleSummaryId, err);
            }
        }

        #endregion

        #region GCPrincipleEventIndicatorImpact

        [Event(500, Level = EventLevel.Informational)]
        public void GCPrincipleEventIndicatorImpact_GetList(Guid principleSummaryId)
        {
            if (IsEnabled())
            {
                WriteEvent(500, principleSummaryId);
            }
        }

        [Event(501, Level = EventLevel.Informational)]
        public void GCPrincipleEventIndicatorImpact_GetList_Success(Guid principleSummaryId)
        {
            if (IsEnabled())
            {
                WriteEvent(501, principleSummaryId);
            }
        }

        [NonEvent]
        public void GCPrincipleEventIndicatorImpact_GetList_Error(Guid principleSummaryId, Exception ex)
        {
            if (IsEnabled())
            {
                GCPrincipleEventIndicatorImpact_GetList_Error(principleSummaryId, ex.ToString());
            }
        }

        [Event(502, Level = EventLevel.Error)]
        public void GCPrincipleEventIndicatorImpact_GetList_Error(Guid principleSummaryId, string err)
        {
            if (IsEnabled())
            {
                WriteEvent(502, principleSummaryId, err);
            }
        }

        #endregion

        #region GCPrincipleEventIndicatorManagement

        [Event(600, Level = EventLevel.Informational)]
        public void GCPrincipleEventIndicatorManagement_GetList(Guid principleSummaryId)
        {
            if (IsEnabled())
            {
                WriteEvent(600, principleSummaryId);
            }
        }

        [Event(601, Level = EventLevel.Informational)]
        public void GCPrincipleEventIndicatorManagement_GetList_Success(Guid principleSummaryId)
        {
            if (IsEnabled())
            {
                WriteEvent(601, principleSummaryId);
            }
        }

        [NonEvent]
        public void GCPrincipleEventIndicatorManagement_GetList_Error(Guid principleSummaryId, Exception ex)
        {
            if (IsEnabled())
            {
                GCPrincipleEventIndicatorManagement_GetList_Error(principleSummaryId, ex.ToString());
            }
        }

        [Event(602, Level = EventLevel.Informational)]
        public void GCPrincipleEventIndicatorManagement_GetList_Error(Guid principleSummaryId, string err)
        {
            if (IsEnabled())
            {
                WriteEvent(602, principleSummaryId, err);
            }
        }

        #endregion

        #region GCPrincipleEventIndicator

        [Event(700, Level = EventLevel.Informational)]
        public void GCPrincipleEventIndicator_GetList(Guid principleSummaryId)
        {
            if (IsEnabled())
            {
                WriteEvent(700, principleSummaryId);
            }
        }

        [Event(701, Level = EventLevel.Informational)]
        public void GCPrincipleEventIndicator_GetList_Success(Guid principleSummaryId)
        {
            if (IsEnabled())
            {
                WriteEvent(701, principleSummaryId);
            }
        }

        [NonEvent]
        public void GCPrincipleEventIndicator_GetList_Error(Guid principleSummaryId, Exception ex)
        {
            if (IsEnabled())
            {
                GCPrincipleEventIndicator_GetList_Error(principleSummaryId, ex.ToString());
            }
        }

        [Event(702, Level = EventLevel.Error)]
        public void GCPrincipleEventIndicator_GetList_Error(Guid principleSummaryId, string err)
        {
            if (IsEnabled())
            {
                WriteEvent(702, principleSummaryId, err);
            }
        }

        #endregion

        #region GCPrincipleSummary

        [Event(800, Level = EventLevel.Informational)]
        public void GCPrincipleSummary_GetList(Guid companyId)
        {
            if (IsEnabled())
            {
                WriteEvent(800, companyId);
            }
        }

        [Event(801, Level = EventLevel.Informational)]
        public void GCPrincipleSummary_GetList_Success(Guid companyId)
        {
            if (IsEnabled())
            {
                WriteEvent(801, companyId);
            }
        }

        [NonEvent]
        public void GCPrincipleSummary_GetList_Error(Guid companyId, Exception ex)
        {
            if (IsEnabled())
            {
                GCPrincipleSummary_GetList_Error(companyId, ex.ToString());
            }
        }

        [Event(802, Level = EventLevel.Error)]
        public void GCPrincipleSummary_GetList_Error(Guid companyId, string err)
        {
            if (IsEnabled())
            {
                WriteEvent(802, companyId, err);
            }
        }

        [Event(900, Level = EventLevel.Informational)]
        public void GCPrincipleSummary_GetCount(Guid companyId)
        {
            if (IsEnabled())
            {
                WriteEvent(900, companyId);
            }
        }

        [Event(901, Level = EventLevel.Informational)]
        public void GCPrincipleSummary_GetCount_Success(Guid companyId)
        {
            if (IsEnabled())
            {
                WriteEvent(901, companyId);
            }
        }

        [NonEvent]
        public void GCPrincipleSummary_GetCount_Error(Guid companyId, Exception ex)
        {
            if (IsEnabled())
            {
                GCPrincipleSummary_GetCount_Error(companyId, ex.ToString());
            }
        }

        [Event(902, Level = EventLevel.Error)]
        public void GCPrincipleSummary_GetCount_Error(Guid companyId, string err)
        {
            if (IsEnabled())
            {
                WriteEvent(902, companyId, err);
            }
        }

        #endregion

        #region GCPrincipleSummaryExtended

        [Event(1000, Level = EventLevel.Informational)]
        public void GCPrincipleSummaryExtended_GetList(Guid companyId)
        {
            if (IsEnabled())
            {
                WriteEvent(1000, companyId);
            }
        }

        [Event(1001, Level = EventLevel.Informational)]
        public void GCPrincipleSummaryExtended_GetList_Success(Guid companyId)
        {
            if (IsEnabled())
            {
                WriteEvent(1001, companyId);
            }
        }

        [NonEvent]
        public void GCPrincipleSummaryExtended_GetList_Error(Guid companyId, Exception ex)
        {
            if (IsEnabled())
            {
                GCPrincipleSummaryExtended_GetList_Error(companyId, ex.ToString());
            }
        }

        [Event(1002, Level = EventLevel.Error)]
        public void GCPrincipleSummaryExtended_GetList_Error(Guid companyId, string err)
        {
            if (IsEnabled())
            {
                WriteEvent(1002, companyId, err);
            }
        }

        #endregion

        #region GCPrincipleEventIndicatorExtended

        [Event(1100, Level = EventLevel.Informational)]
        public void GCPrincipleEventIndicatorExtended_GetList(Guid companyId)
        {
            if (IsEnabled())
            {
                WriteEvent(1100, companyId);
            }
        }

        [Event(1101, Level = EventLevel.Informational)]
        public void GCPrincipleEventIndicatorExtended_GetList_Success(Guid companyId)
        {
            if (IsEnabled())
            {
                WriteEvent(1101, companyId);
            }
        }

        [NonEvent]
        public void GCPrincipleEventIndicatorExtended_GetList_Error(Guid companyId, Exception ex)
        {
            if (IsEnabled())
            {
                GCPrincipleEventIndicatorExtended_GetList_Error(companyId, ex.ToString());
            }
        }

        [Event(1102, Level = EventLevel.Error)]
        public void GCPrincipleEventIndicatorExtended_GetList_Error(Guid companyId, string err)
        {
            if (IsEnabled())
            {
                WriteEvent(1102, companyId, err);
            }
        }

        #endregion GCPrincipleEventIndicatorExtended

        #region GCSource

        [Event(1200, Level = EventLevel.Informational)]
        public void GCSource_GetList(Guid companyId)
        {
            if (IsEnabled())
            {
                WriteEvent(1200, companyId);
            }
        }

        [Event(1201, Level = EventLevel.Informational)]
        public void GCSource_GetList_Success(Guid companyId)
        {
            if (IsEnabled())
            {
                WriteEvent(1201, companyId);
            }
        }

        [NonEvent]
        public void GCSource_GetList_Error(Guid companyId, Exception ex)
        {
            if (IsEnabled())
            {
                GCSource_GetList_Error(companyId, ex.ToString());
            }
        }

        [Event(1202, Level = EventLevel.Error)]
        public void GCSource_GetList_Error(Guid companyId, string err)
        {
            if (IsEnabled())
            {
                WriteEvent(1202, companyId, err);
            }
        }

        #endregion GCSource

        #region GCExport

        [Event(1300, Level = EventLevel.Informational)]
        public void GCExport_GetPdfExport(Guid companyId)
        {
            if (IsEnabled())
            {
                WriteEvent(1300, companyId);
            }
        }

        [Event(1301, Level = EventLevel.Informational)]
        public void GCExport_GetPdfExport_Success(Guid companyId)
        {
            if (IsEnabled())
            {
                WriteEvent(1301, companyId);
            }
        }

        [NonEvent]
        public void GCExport_GetPdfExport_Error(Guid companyId, Exception ex)
        {
            if (IsEnabled())
            {
                GCExport_GetPdfExport_Error(companyId, ex.ToString());
            }
        }

        [Event(1302, Level = EventLevel.Error)]
        public void GCExport_GetPdfExport_Error(Guid companyId, string err)
        {
            if (IsEnabled())
            {
                WriteEvent(1302, companyId, err);
            }
        }

        #endregion
    }
}
